<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/12/6
 * Time: 10:37
 */
if(empty($_POST['username'])){
    echo '用户名为空';
    echo '<br />';
    echo '<a href="index.php">重新输入</a>';
    die;
}else{
    $username = $_POST['username'];
}

if(empty($_POST['password'])){
    echo '密码为空';
    echo '<br />';
    echo '<a href="index.php">重新输入</a>';
    die;
}else{
    $password = $_POST['password'];
}

if(!empty($_COOKIE['Token'])){
    echo '你的用户编号为: '.$_COOKIE['Token'];
    echo '<br />';
    echo '<a href="index.php">退出登入</a>';
}else{
    echo '你尚未登入，请登入';
    echo '<br />';
    echo '<a href="index.php">重新登录</a>';
    die;
}

if ($username=='admin' && $password=='888888'){
    echo '<h3>上传头像</h3>';
}else{
    echo '账号或密码错误！';
    echo '<br />';
    echo '<a href="index.php">重新登录</a>';
    die;
}
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
</head>
<body>
<form action="upload.php" method="post" enctype="multipart/form-data">
    <input type="file"  name="file" id="file" multiple="multiple" onchange="showImg1()" >
    <br />
    <img src="" id="showImg" width="100px" height="100px">
    <input type="submit" id="" value="提交" />
</form>
<!--    <button onclick="showImg();">显示图片</button>-->
</body>


<script type="text/javascript">
    var fileObj = document.getElementById('file');
    function showImg1() {

        var files = fileObj['files'];
        var URL = window.URL || window.webkitURL;
        var imgURL = URL.createObjectURL(files[0]);
        document.getElementById('showImg').src = imgURL;
    }
</script>
</html>

